﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace Sale_Common
{
    public class ExcelHandler
    {
        public static DataTable GetTableFrom(string strExcelFilePath,string strTableName)
        {
            string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strExcelFilePath+";Extended Properties=Excel 8.0";
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = strCon;
            OleDbDataAdapter adapter = new OleDbDataAdapter(" SELECT * FROM ["+strTableName+"$]", con);
            DataSet ds = new DataSet();
            adapter.Fill(ds);
            return ds.Tables[0];
        }
    }
}
